package controller;

import java.io.IOException;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import dao.XxDao;

/**
 * Servlet implementation class UpdateUserServlet
 */
@WebServlet("/XxFdyUpdateServlet")
public class XxFdyUpdateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
	        String classid = request.getParameter("class");
	         //以上为更新提交后的信息,以下为旧信息
	        String oldid = request.getParameter("oldid");
	        String oldclass = request.getParameter("oldclass");
	        
	        XxDao dao = new XxDao();
	        
	        
	        boolean success = dao.updateFdyXx(oldid,oldclass,classid);
	        
	        if (success) {
	            response.sendRedirect("View_xx/XxFdy.jsp"); // 更新成功后跳转到用户列表页面
	        } else {
	            response.getWriter().write("UPDATEFAILE");
	        }
	}

}